package cn.tac.test.spring.bean.xml.processor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * 该processor注册后会对所有bean生效
 * @author : tac
 * @date : 15/04/2017
 */
public class BeanLogProcessor implements BeanPostProcessor {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        logger.info("bean " + beanName + "初始化开始");
        return  bean;
    }

    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        logger.info("bean " + beanName + "初始化完成");
        return bean;
    }
}
